//
//  Rectangle.m
//  Racing
//
//  Created by vy phan on 4/12/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Rectangle.h"

@implementation Rectangle

/* class method to construct a rectangle */
+ (id)x:(int)xValue y:(int)yValue width:(int)aWidth height:(int)aHeight {
	id newInstance = [[Rectangle alloc] init];
	
	[newInstance x:xValue];
	[newInstance y:yValue];
	[newInstance width:aWidth];
	[newInstance height:aHeight];
	return newInstance;
}

/* get the height of the rectangle */
- (int)height {
	return height;
}

/* get the width of the rectangle */
- (int)width {
	return width;
}

/* set the height of the rectangle */
- (int)height:(int)aNumber {
	height = aNumber;
	return height;
}

/* set the width of the rectangle */
- (int)width:(int)aNumber {
	width = aNumber;
	return width;
}

/* point in rectangle or not */
- (BOOL)contains:(int)xValue Y:(int)yValue {
	if (xValue <= self->x + self->width
		&&
		xValue >= self->x
		&&
		yValue <= self->y + self->height
		&&
		yValue >= self->y
		) {
		return YES;
	}
	else {
		return NO;
	}

}
/* draw the rectangle */
//- draw {
//	printf("Drawing a Rectangle at:(%d,%d), width %d, height %d\n",
//		   [self x], [self y], [self width], [self height]);
//}

@end